package cn.edu.heuet.bnve.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import cn.edu.heuet.bnve.R;

public class StringUtil {
    public static int getAlarmText(int i) {
        switch (i) {
            case -1:
                return R.string.text_alarm_time;
            case 0:
                return R.string.text_alarm_time0;

            case 1:
                return R.string.text_alarm_time1;

            case 2:
                return R.string.text_alarm_time2;
            case 3:
                return R.string.text_alarm_time3;

            default:
                return R.string.text_alarm_time;
        }
    }

    public static int getDate(String formatStr, Date date) {
        SimpleDateFormat format = new SimpleDateFormat(formatStr);
        return Integer.parseInt(format.format(date));
    }
    public static int getWeek(Date date){
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
        if(week_index<0){
            week_index = 0;
        }
        return week_index;
    }

}
